{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no, viewport-fit=cover" />
    <link rel="stylesheet" type="text/css" href="/agent/school/common.css"/>
    <link rel="stylesheet" type="text/css" href="/agent/school/list.css"/>
    <script type="text/javascript" src="/agent/manage/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/agent/manage/js/rem.js" ></script>
    <script type="text/javascript" src="/agent/manage/js/mescroll.min.js" ></script>
    <link rel="stylesheet" type="text/css" href="/agent/manage/css/mescroll.min.css"/>
    <link rel="stylesheet" type="text/css" href="/agent/serial/css/mobileSelect.css">
    <script src="/agent/serial/js/mobileSelect.js" type="text/javascript"></script>
    <title>学校管理</title>
</head>
<body>
    <div class="top">
        <form id="searchForm" name="searchForm" method="get" action="" onsubmit="">
            <div class="top_left" id="trigger1">
                <span class="top_left_con1">
                    {if $areaRow.mergename}
                        {$areaRow.mergename}
                    {else}
                        地区
                    {/if}
                </span>
                <img class="top_left_xia1" src="/agent/school/img/jtxia.png" />
                <img class="top_left_up1" src="/agent/school/img/jtup.png" />
            </div>
            <input type="hidden" id="product" name="province" value="{$where.province}">
            <input type="hidden" id="kemu" name="city" value="{$where.city}">
            <input type="hidden" id="banben" name="area" value="{$where.area}">
            <div class="top_right">
                <span class="top_left_con2">
                    {if $where.type == 1}
                        小学
                    {elseif $where.type == 2}
                        初中
                    {elseif $where.type == 3}
                        高中
                    {else}
                        类别
                    {/if}
                </span>
                <img class="top_left_xia2" src="/agent/school/img/jtxia.png" />
                <img class="top_left_up2" src="/agent/school/img/jtup.png" />
                <input type="hidden" id="type" name="type" value="{$where.type}">
            </div>
        </form>
        <div class="sou"></div>
        <div class="cate_mid">
            <form id="searchs" name="searchs" method="get" action="" onsubmit="">
                <div class="text_box" name="list_search_text_box" onclick="">
                    <input id="keyword" name="search" type="text" placeholder="请输入学校名称" class="text" value="{$search}">
                    <input type="submit" value="" class="submit" id="list_search_submit">
                    <div class="close">取消</div>
                </div>
            </form>
        </div>
    </div>

<ul class="examine">
    <li class="lisearch" {$where.type? '':'style="color: #457bc7;"'} data-text="" >全部<img src="/agent/school/img/jtyou.png" /></li>
    <li class="lisearch" {$where.type == 1 ? 'style="color: #457bc7;"':''} data-text="1">小学<img src="/agent/school/img/jtyou.png" /></li>
    <li class="lisearch" {$where.type == 2 ? 'style="color: #457bc7;"':''} data-text="2">初中<img src="/agent/school/img/jtyou.png" /></li>
    <li class="lisearch" {$where.type == 3 ? 'style="color: #457bc7;"':''} data-text="3">高中<img src="/agent/school/img/jtyou.png" /></li>
</ul>
<div id="mescroll" class="mescroll">
    <ul class="list" >
        <!--<li>
            <a href="add_ruku.html">
                <p class="info">北京小学</p>
                <div class="date">
                    <span class="date_left">地址：北京小学北京小学</span>
                </div>
            </a>
        </li>-->

    </ul>
</div>
<a href="/agent/school/add"><div class="pay">新增</div></a>
</body>
<script type="text/javascript" src="/agent/school/school.js"></script>
<script>

  var param = window.location.search;
  var mescroll = new MeScroll("mescroll", { //第一个参数"mescroll"对应上面布局结构div的id
    //如果下拉刷新是重置列表数据,那么down完全可以不用配置
    down: {
      callback: downCallback //下拉刷新的回调
    },
    up: {
      auto:false,//在初始化完毕之后自动执行下拉刷新的回调  true  false
      htmlNodata: '<p class="upwarp-nodata">没有更多了..</p>',
      page: {
        num: 0,
        size: 10,
        time: null
      },
      callback: upCallback    //上拉加载的回调
    }
  });

  var pageSize = 10;
  function downCallback(page) {
    $.ajax({
      url: '/agent/school/index'+param+'&Pagesize='+pageSize+'&page=1',
      type: 'get',
      data:{},
      success: function (res) {
        $('.list').html('');
        mescroll.resetUpScroll();
      },
      error: function () {
        // 联网失败的回调,隐藏下拉刷新的状态
        mescroll.endErr();
      }

    })
  }
  function upCallback(page) {
    $.ajax({
      url: '/agent/school/index'+param+'&Pagesize='+pageSize+'&page='+page.num,
      type: 'get',
      success: function (res) {
        var list = res.rows.data;
        if(list.length > 0) { //有数据
          $('.list').append(render(list));
        }
        if (res.rows.data && res.rows.data.length == page.size) {
          //联网成功的回调,隐藏下拉刷新的状态（参数：当前页的数据个数, 是否有下一页true/false）;
          mescroll.endSuccess(res.rows.data.length, true);
        } else {
          //联网成功的回调,隐藏下拉刷新的状态（参数：当前页的数据个数, 是否有下一页true/false）;
          mescroll.endSuccess(res.rows.data.length, false);
        }
      },
      error: function () {
        // 联网失败的回调,隐藏下拉刷新的状态
        mescroll.endErr();
      }
    })
  }
  function render(data)
  {
    var html ='';
    $.each(data,function (index,value) {
      html +='<li>\n' +
        '            <a href="/agent/school/edit/id/'+value.id+'">\n' +
        '                <p class="info">'+value.name+'</p>\n' +
        '                <div class="date">\n' +
        '                    <span class="date_left">地址：'+value.address+'</span>\n' +
        '                </div>\n' +
        '            </a>\n' +
        '        </li>';
    });
    return html;
  }

  var mobileSelect4 = new MobileSelect({
    trigger: '#trigger1',
    title: '地区选择',
    wheels: [{data:[
        {
          id:'1',
          value:'',
          childs:[
            {id:'A1',value:''},
          ]
        }
      ]}],
    transitionEnd:function(indexArr, data){
    },
    callback:function(indexArr, data){
      $('#product').val(data[0].id);
      $('#kemu').val(data[1].id);
      $('#banben').val(data[2].id);
      $('#trigger1').val(data[0].value+' -> '+data[1].value+' -> '+data[2].value);

    }
  });
  $('.ensure').click(function () {
    $('#searchForm').submit();
  });
  $('.cancel').click(function () {
    $('#product').val('');
    $('#kemu').val('');
    $('#banben').val('');
    $('#searchForm').submit();
  });
  $('.lisearch').click(function () {
    $('#type').val($(this).attr('data-text'));
    $('#searchForm').submit();
  });
  $.ajax({
    type: "get",
    url: "/api/ajax/area",
    dataType: "json",
    success: function(res){
      mobileSelect4.updateWheels(res.data);
    }
  });
</script>

</html>
